﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace TK.Socket.ServerDemo
{
    class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((host, config) =>
            {
                config.AddJsonFile("socket.json", true, true);
            })
            .ConfigureLogging(log =>
            {
                log.ClearProviders();
                log.SetMinimumLevel(LogLevel.Trace).AddConsole().AddDebug();
            })
            .ConfigureServices((host, services) =>
            {
                //services.AddSocketService(m => { m.IPConfigList.Add(new IPConfig { IP = "192.168.31.173", Port = 9000, SocketType = SocketTypeEnum.Tcp }); });
                //services.AddSingleton<IReceiveDataHandler, MyReceiveHandler>();
                services.AddSocketService().AddSokcetDataHandler<MyReceiveHandler>();               
            });

    }
}
